package com.tuniu.agents.common.entity.itinerary.resource;

import com.tuniu.agents.common.entity.itinerary.Resource;
import com.tuniu.agents.common.entity.itinerary.enums.ResourceStatus;
import com.tuniu.agents.common.entity.itinerary.enums.ResourceType;

import java.math.BigDecimal;
import java.util.Objects;

public class HotelResource extends Resource {

    /**
     * hotel name
     */
    private String hotelName;

    /**
     * check in date, format: yyyy-MM-dd
     */
    private String checkIn;

    /**
     * check out date, format: yyyy-MM-dd
     */
    private String checkOut;

    /**
     * false hotel, true hotel-package
     */
    private boolean isPackage;

    public HotelResource(){
    }
    public HotelResource(String hotelName, String checkIn, String checkOut, String markdown, BigDecimal price, ResourceStatus status) {
        super(ResourceType.HOTEL, checkIn, null, markdown, price, status);
        this.hotelName = hotelName;
        this.checkIn = checkIn;
        this.checkOut = checkOut;
    }

    public HotelResource(String hotelName, String checkIn, String checkOut, Object data, String markdown, BigDecimal price, ResourceStatus status) {
        super(ResourceType.HOTEL, checkIn, data, markdown, price, status);
        this.hotelName = hotelName;
        this.checkIn = checkIn;
        this.checkOut = checkOut;
    }

    @Override
    public boolean match(Resource resource) {
        if (this == resource) {
            return true;
        }
        if (!(resource instanceof HotelResource)) {
            return false;
        }

        HotelResource hotelResource = (HotelResource) resource;
        return Objects.equals(hotelName, hotelResource.hotelName) &&
                Objects.equals(checkIn, hotelResource.checkIn);
    }

    @Override
    public String createTemplateName() {
        if (!isPackage) {
            return "hotel/hotel-list-one.ftlh";
        } else {
            return "hotel/hotel-package-list-one.ftlh";
        }
    }

    public String getHotelName() {
        return hotelName;
    }

    public void setHotelName(String hotelName) {
        this.hotelName = hotelName;
    }

    public String getCheckIn() {
        return checkIn;
    }

    public void setCheckIn(String checkIn) {
        this.checkIn = checkIn;
    }

    public String getCheckOut() {
        return checkOut;
    }

    public void setCheckOut(String checkOut) {
        this.checkOut = checkOut;
    }
}
